<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
	</head>
	<body>
		<div id="app">
			<div class="header">
				<span>删除快递员</span>
			</div>
			<div class="content">
				<table>	
					<tr>
						<td class="text-right">手机号码</td><td class="content_right"><input class="input inline-input" placeholder="请输入手机号码" id="userPhone"> <span class="btn btn-info" id="find">立即查找</span></td>
					</tr>
				</table>
			</div>
			
			
			<div class="header">
				<span>查找信息如下</span>
			</div>
			<div class="content">
				<table>
					<tr>
						<td class="text-right">姓名</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">手机号码</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">身份证号码</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">密码</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td></td><td class="content_right"><span class="btn btn-info" id="delete">立即删除</span> <span class="btn">重置</span> </td>
					</tr>
				</table>
			</div>
		</div>
	</body>
	<script src="/qrcode/jquery2.1.4.js"></script>
	<script src="/layer/layer.js"></script>
	<script>
		$(".header:eq(1),.content:eq(1)").hide();//查询前，先隐藏展示查询结果的table
		var courierId=null; //定义全局变量:id，修改时需要使用
		$(function () {
			$("#find").click(function () { //绑定点击事件
				var windowId = layer.load();//加载的弹出层效果
				var userPhone = $("#userPhone").val();//获取输入表单的手机号
				$.getJSON("/courier/find.do",{phone:userPhone},function (data) {//发送ajax请求到服务器
					//{"status":0,"result":"查询成功","data":{"id":10,"number":"123123123","username":"李四","userPhone":"123456789","company":"顺丰快递","code":"819821","inTime":"Apr 2, 2021, 12:38:47 AM","status":0,"sysPhone":"123456789"}}
					layer.close(windowId);//关闭加载层
					layer.msg(data.result);//显示执行结果
					if (data.status==0){ //成功
						$(".header:eq(1),.content:eq(1)").fadeIn(2000);//将展示查询结果的table淡入出来
						courierId=data.data.id; //获取通过手机查询到的快件的id，过会根据id去更新
						$("input:eq(1)").val(data.data.username); //根据查询的快递填充到table表单中
						$("input:eq(2)").val(data.data.userPhone);
						$("input:eq(3)").val(data.data.cardId);
						$("input:eq(4)").val(data.data.password);
					}
				});
			});

			$("#delete").click(function () {
				var windowId = layer.load();
				$.getJSON("/courier/delete.do",{id:courierId},function (data) {
					layer.close(windowId);
					layer.msg(data.result);
					if (data.status==0){
						//删除成功
						$(".header:eq(1),.content:eq(1)").hide();
						$("#userPhone").val("");
					}
				});

			});
		})
	</script>

</html>
